	/**
	 * Object: Kombai;
	 *          the interface of program, using to create database in browser;
	 *          copyright (c) 2009 uoon (http://vnjs.net);
	 * Version: 1.0;
	 * License: GPL license;
	 * Email: mnx2012@gmail.com;
	 * Properties:
	 * 		archiver - store global varialbe : object, function, number...;
	 * 		K - store all method of programe;
	 */
	var Kombai = {
		archive: {
			data: {},
			method: {},
			variable: {}
		},
		K: {
			add: {},
			get: {},
			set: {},
			check: {},
			remove: {},
			create: {},
			insert: {},
			select: {},
			request: {}
		}
	};

	/**
	 * Returns an object and some extend function matches the type of object input or the id of element node;
	 * @param {Object} R
	 * Example:
	 * 		var str = "   demo string  ";
	 *
	 * 		alert(K(str).trim());
	 * 		//alerts 'demo string';
	 *
	 * 		var ele = K('content-area');
	 * 		//returns the element node that has the id matches 'content-area';
	 *
	 * 		K('content-area').show();
	 * 		//set display style of element value is 'block';
	 */
	Kombai.K = K = function(R) {
		var E = document.getElementById(R) || R;
		if (E.String || K.check.isString(E)) {
			E = E.String || E;
			if (!E.isEncode) {
				E = new String(E);
			}
			/**
			 * Trim white space form a string;
			 * Returns a string;
			 * Example:
			 * 		var str = "   demo string  ";
			 * 		alert(K(str).trim());
			 * 		//alerts 'demo string';
			 */
			E.trim = function() {
				var ADN = this;
				return K({String: K.remove.space(ADN)});
			};
			/**
			 * Change one by one character of the string to ASCII code, using to compares bettwen two string;
			 * Returns a string;
			 * Example:
			 *		var str = "   demo string  ";
			 * 		alert(K(str).encode());
			 * 		//alerts '32.32.32.100.101.109.111.32.115.116.114.105.110.103.32.32';
			 */
			E.encode = function() {
				var ADN = this;
				var A = [];
				var L = ADN.length;
				for (var o = 0 ; o < L; ++ o) {
					A.push(ADN.charCodeAt(o));
				}
				ADN = new String(A.join("."));
				ADN.isEncode = true;
				return K({String: ADN});
			};
			/**
			 * To the contrary of E.encode();
			 * Returns a string;
			 */
			E.decode = function() {
				var ADN = this;
				if (ADN.isEncode) {
					var A = ADN.split(".");
					var L = A.length;
					ADN = new String();
					for (var o = 0; o < L; ++ o) {
						ADN += String.fromCharCode(A[o]);
					}
				}
				return K({String: ADN});
			};
			/**
			 * Encode by encodeURIComponent();
			 * Returns a string;
			 * Example:
			 *		var str = "   demo string  ";
			 *		alert(K(str).urlEncode());
			 * 		//alerts '%20%20%20demo%20string%20%20';
			 */
			E.urlEncode = function() {
				var ADN = this;
				return K({String: encodeURIComponent(ADN)});
			};
			/**
			 * Decode by function decodeURIComponent();
			 * Returns a string;
			 * Example:
			 *		var str = "demo%20string%20%20";
			 *		alert(K(str).urlEncode());
			 * 		//alerts 'demo string  ';
			 */
			E.urlDecode = function() {
				var ADN = this;
				return K({String: decodeURIComponent(ADN)});
			};
		} else if (E.Element || K.check.isElement(E)) {
			E = E.Element || E;
			if (K.check.isString(R)) {
				/**
				 * Using extend method of String;
				 * Returns a string;
				 */
				R = K({String: R});
				E.trim = function() {
					return R.trim();
				};
				E.encode = function() {
					return R.encode();
				};
				E.decode = function() {
					return R.decode();
				};
				E.urlEncode = function() {
					return R.urlEncode();
				};
				E.urlDecode = function() {
					return R.urlDecode();
				};
			}
			/**
			 * Add css class, event, style, attribute for the element node;
			 * Returns this element node;
			 * @param {JSON object} r
			 * Example:
			 * 		K('kombai').add({
			 * 			className: "button",
			 * 			attribute: {
			 * 				"name" : "uoon",
			 * 				"title" : "kombai"
			 * 			},
			 * 			style: {
			 * 				border: "1px solid red",
			 * 				fontWeight: "bold"
			 * 			},
			 * 			event: {
			 *          	click: function() {
			 *              	alert('click event');
			 *              },
			 *              mouseout: function() {
			 *              	alert('onmouseout');
			 *              }
			 *              // other event;
			 *          }
			 * 		});
			 *
			 * 		//orther example;
			 * 		K('kombai').add({event: {click: function(){alert(this.innerHTML);}}});
			 */
			E.add = function(r) {
				var ADN = this;
				r.element = ADN;
				K.add(r);
				return K({Element: ADN});
			};
			/**
			 * Set value of display style is 'none';
			 * Returns this element node;
			 * Example:
			 * 		K('kombai').hide();
			 */
			E.hide = function() {
				var ADN = this;
				ADN.style.display = "none";
				return K({Element: ADN});
			};
			/**
			 * Set value of display style is 'block';
			 * Returns this element node;
			 * Example:
			 * 		K('kombai').hide();
			 *
			 * 		K('connector').add({className: "done"}).show();
			 */
			E.show = function() {
				var ADN = this;
				ADN.style.display = "block";
				ADN.style.visibility = "visible";
				return K({Element: ADN});
			};
			/**
			 * Returns the next Element node in DOM if it exists and null if it not exists;
			 * Example:
			 * 		K('popup').next().show();
			 *
			 * 		var popup = document.getElementById('popup');
			 * 		K(popup).next().hide().add({attribute:{'show': false}});
			 */
			E.next = function() {
                var ADN = K.get.nextElement(this);
				return ADN ? K({Element: ADN}) : null;
			};
			/**
			 * Returns the previous Element node in DOM;
			 * Example:
			 * 		var head = K(document.body).prev();
			 */
			E.prev = function() {
                var ADN = K.get.previousElement(this);
				return ADN ? K({Element: ADN}) : null;
			};
			/**
			 * Returns the last child of Element node;
			 * Example:
			 * 		var kombai = K(document.body).last();
			 */
			E.last = function() {
                var ADN = K.get.lastChild(this);
				return ADN ? K({Element: ADN}) : null;
			};
			/**
			 * Returns the first child of Element node;
			 * Example:
			 * 		var editor = K('popup').first();
			 */
			E.first = function() {
				var ADN = K.get.firstChild(this);
                return ADN ? K({Element: ADN}) : null;
			};
			/**
			 * Inserts an element node into DOM;
			 * @param {JSON object} r
			 * Using one of the following values to direct:
			 *		beforeBegin: Inserts Element immediately before the object;
			 *		afterBegin: Inserts Element after the start of the object but before all other content in the object;
			 *		beforeEnd: Inserts Element immediately before the end of the object but after all other content in the object;
			 *		afterEnd: Inserts Element immediately after the end of the object;
			 * Example:
			 * 		K('kombai').insert({
			 * 			element: K('login-form'),
			 * 			where: 'beforeEnd'
			 * 		});
			 */
			E.insert = function(r) {
				var ADN = this;
				r.refer = ADN;
				K.insert(r);
				return K({Element: ADN});
			};
			/**
			 * Returns an array of Element nodes with specified clause;
			 * @param {JSON object} r
			 * Example:
			 * 		//gets all images has title is 'copyright uoon' in 'kombai' node;
			 * 		var imgs = K('kombai').select({
			 * 			where: "tagName =='IMG' && title == 'copyright uoon'"
			 * 		});
			 *
			 * 		//gets all DIV node has css class include keyword 'popup' in 'kombai' node;
			 * 		var aPopup = K('kombai').select({where: "tagName == 'DIV' && className like '%popup%'"});
			 *
			 *  	K('menu').select({
			 *  		where: "className == 'tab'",
			 *  		formatWith: function(row, index) {
			 *  			//refer to element node;
			 *  			var self = row;
			 *  			//set innerHTML;
			 *  			self.innerHTML = 'Item' + index;
			 *  		}
			 *  	});
			 */
			E.select = function(r) {
				var ADN = this;
				r.from = ADN;
				return K.select(r);
			};
			/**
			 * Set opacity value for an element node, accept value between 0 and 100;
			 * Return this element node;
			 * @param {Number} r
			 * Example:
			 * 		K('kombai').opacity(40);
			 */
			E.opacity = function(r) {
				var ADN = this;
				if (K.check.isNumber(r)) {
					if (K.check.isIE()) {
						ADN.style.filter = "alpha(opacity = r)".replace("r", r);
					} else {
						ADN.style.opacity = r/100;
					}
				}
				return K({Element: ADN});
			};
			/**
			 * Creates some animations;
			 * @param {JSON object} r
			 * Example:
			 * 		K('animation').transform({
			 * 			// try transition value between 0 and 5;
			 * 			// 4 is elastic engine effect;
			 * 			// 5 is bounce engine effect;
			 * 			transition: 4,
			 * 			width: '930',
			 * 			//default unit is 'px' other accept 'em' and '%';
			 * 			unit: 'px',
			 * 			onRelease: function() {
			 * 				alert('done');
			 * 			}
			 * 		});
			 *
			 * 		//animations with color;
			 * 		K('animation').transform({
			 * 			color: '#effffe',
			 * 			top: '300'
			 * 		});
			 *
			 *		K('animation').transform({
			 * 			color: ['#effffe', '#ffffff'],
			 * 			top: '300'
			 * 		});
			 *
			 * 		//creates dynamic effect;
			 * 		K('animation').transform({
			 *      	transition: function(x){
			 *          	return x*sin(x);
			 *          },
			 *          height: '200',
			 *          unit: '%'
			 *      });
			 *
			 */
			E.transform = function(r) {
				var ADN = this;
				var transition = {
					0: function(x) {
						return x;
					},
					1: function(x) {
						return x*(2 - x);
					},
					2: function(x) {
						return Math.pow(x, 2);
					},
					3: function(x) {
						return Math.pow(x, 1/2);
					},
					//elastic effect;
					4: function(x) {
						var t = 1 + 1 + 1/2 + 1/4, a = t*t/2;
						if (x < (2/t)) {
							return -a*x*x + t*1.5*x;
						} else if (x < (2.5/t)) {
							return a*x*x - t*2.25*x + 3.5;
						} else {
							return -a*x*x + t*2.625*x - 2.4375;
						}
					},
					//bounce effect;
					5: function(x) {
						var t = 1 + 1 + 1/2 + 1/4, a = t*t, b = -2*t;
						//parabol :  a x^2 + bx +  c = 1;
						if (x < (1/t)) {
							return a*x*x;
						} else if (x < (2/t)) {
							return a*x*x + b*1.5*x + 3;
						} else if (x < (2.5/t)) {
							return a*x*x + b*2.25*x + 6;
						} else {
							return a*x*x + b*2.625*x + 7.875;
						}
					}
				},
				setting = {
					delay: r.delay || 17,
					times: r.times || 92,
					unit: (r.unit !== undefined) ? r.unit : "px",
					onStart: r.onStart || function() {},
					onRelease: r.onRelease || function() {},
					transition: K.check.isFunction(r.transition) ?
									r.transition : (transition[r.transition]) ?
										transition[r.transition] : transition[1]
				},
				color = {
					decToHex: function(d) {
						var hex = d.toString(16);
						while (hex.length != 6) {
							if (hex.length < 6) {
								hex = "0" + hex;
							} else {
								hex = hex.substring(0, 6);
							}
						}
						return "#" + hex;
					},
					hexToDec: function(h) {
						return parseInt(h.replace("#", ""), 16);
					},
					r: 0,
					g: 0,
					b: 0,
					delta: function(m) {
						return 	65536*Math.round(m*this.r) +
								256*Math.round(m*this.g) +
								Math.round(m*this.b);
					}
				},
				style = [
					"background",
					"backgroundColor",
					"backgroundImage",
					"backgroundPosition",
					"borderColor",
					"bottom",
					"color",
					"font",
					"fontColor",
					"fontSize",
					"height",
					"left",
					"letterSpacing",
					"lineHeight",
					"listStyleImage",
					"listStylePosition",
					"margin",
					"marginTop",
					"marginRight",
					"marginBottom",
					"marginLeft",
					"padding",
					"paddingTop",
					"paddingRight",
					"paddingBottom",
					"paddingLeft",
					"right",
					"size",
					"top",
					"width",
					"wordSpacing",
					"zIndex",
					"opacity",
					"outlineOffset"
				];
				style.color = ["backgroundColor", "borderColor", "color", "fontColor"];
				style.position = ["top", "right", "bottom", "left"];
				//update new init;
				if (ADN.t92 && ADN.t92.timer) {
					for (var o in ADN.t92.timer) {
						if (K.check.isNumber(ADN.t92.timer[o])) {
							K.remove.timeout(ADN.t92.timer[o]);
						}
					}
				}
				ADN.t92 = {
					timer: [],
					revolve: []
				};
				setting.onStart();
				for(var o in style.position) {
					var styleName = style.position[o];
					if (r[styleName] !== undefined) {
						ADN.style.position = (K.get.currentStyle(ADN, "position") != "absolute") ?
												"relative" : "absolute";
						break;
					}
				}
				for (var o in style) {
					var styleName = style[o];
					if (r[styleName] !== undefined) {
						registerStyle(styleName, r[styleName]);
						ADN.t92.revolve[styleName]();
					}
				}
				function registerStyle(styleName, value) {
					ADN.t92[styleName] = {
						step: 0,
						from: null,
						value: null,
						target: null,
						transformColor: false,
						usingCollection: false
					};
					var t92 = ADN.t92[styleName];
					//check transform color;
					for (var o in style.color) {
						if (styleName === style.color[o]) {
							t92s.transformColor = true;
							break;
						}
					}
					//format target value;
					if ((K.check.isArray(value) && value.length > 2)) {
						t92s.usingCollection = true;
						t92s.value = value;
					} else if (K.check.isArray(value) && value.length == 2) {
						t92s.from = value[0];
						t92s.target = value[value.length - 1];
						if (t92s.transformColor) {
							t92s.from = color.hexToDec(t92s.from);
							t92s.target = color.hexToDec(t92s.target);
						}
					} else {
						t92s.from = K.get.currentStyle(ADN, styleName);
						t92s.from = t92s.transformColor ?
										color.hexToDec(t92s.from) : isNaN(parseFloat(t92s.from)) ?
											0 : parseFloat(t92s.from);
						t92s.target = t92s.transformColor ? color.hexToDec(value) : value;
					}
					//create range value;
					if (t92s.target !== null && t92s.from !== null) {
						var delta = t92s.target - t92s.from;
						if (t92s.transformColor) {
							var abs = Math.abs(delta);
							var dir = delta/abs;
							color.r = Math.floor(abs/65536);
							color.g = Math.floor(abs/256 - color.r*256);
							color.b = abs - color.g*256 - color.r*65536;
							color.r *= dir;
							color.g *= dir;
							color.b *= dir;
							t92s.usingCollection = true;
						}
						t92s.value = [];
						for (var o = 0; o < setting.times; ++o) {
							var x = o/setting.times;
							if (t92s.transformColor) {
								var hexCode = t92s.from + color.delta(setting.transition(x));
								t92s.value.push(color.decToHex(parseInt(hexCode)));
							} else {
								t92s.value.push(t92s.from + setting.transition(x)*delta);
							}
						}
					}
					//main function;
					ADN.t92.revolve[styleName] = function() {
						++ t92s.step;
						if (t92s.step < t92s.value.length) {
							if (t92s.usingCollection) {
								ADN.style[styleName] = t92s.value[t92s.step];
							} else if (styleName == "opacity") {
								ADN.opacity(t92s.value[t92s.step]);
							} else {
								ADN.style[styleName] = t92s.value[t92s.step] + setting.unit;
							}
							ADN.t92.timer[styleName] = setTimeout(ADN.t92.revolve[styleName], setting.delay);
						} else {
							if (t92s.usingCollection) {
								ADN.style[styleName] = t92s.value[t92s.value.length -1];
							} else if (styleName == "opacity") {
								ADN.opacity(t92s.target);
							} else {
								ADN.style[styleName] = t92s.target + setting.unit;
							}
							clearTimeout(ADN.t92.timer[styleName]);
							ADN.t92.timer[styleName] = null;
							onRelease();
						}
					};
				}
				function onRelease() {
					for (var o in ADN.t92.timer) {
						if (!Object.prototype[o] && ADN.t92.timer[o]) {
							return;
						}
					}
					setting.onRelease();
					ADN.t92 = null;
				}
				return K({Element: ADN});
			};
			/**
			 * Creates dragdrop effect;
			 * @param {JSON object} r
			 * Example:
			 * 		//normal init;
			 * 		K('kombai').initDragDrop();
			 *
			 * 		//dragdrop with event;
			 * 		K('kombai').initDragDrop({
			 * 			onDrag: function() {
			 * 				//refer this node;
			 * 				var element = this.self;
			 * 				//refer event;
			 * 				var event = this.event;
			 * 				//do some thing;
			 * 			},
			 * 			onMove: function() {
			 * 				//do some thing;
			 * 			},
			 * 			onDrop: function() {
			 * 				alert('done');
			 * 			}
			 * 		});
			 *
			 * 		//dragdrop with proxy object;
			 * 		K('kombai').initDragDrop({
			 * 			onDrag: function() {
			 * 				var element = this.self;
			 * 				var event = this.event;
			 * 				var proxy = element.assign();
			 * 				K(proxy).opacity(40).style.position = 'absolute';
			 * 			}
			 * 		});
			 */
			E.initDragDrop = function(r) {
				if (r === undefined) {
					var r = {};
				}
				var ADN = this;
				ADN.store = {
					x: 0,
					y: 0,
					X: 0,
					Y: 0
				};
				ADN.event = {
					mouseDown: function() {},
					mouseMove: function() {},
					mouseUp: function() {}
				};
				ADN.run = {
					drag: r.onDrag || function() {},
					move: r.onMove || function() {},
					drop: r.onDrop || function() {}
				};
				ADN.drop = function() {
					ADN.store = null;
					ADN.event = null;
					ADN.run = null;
					ADN.drop = function() {};
                    ADN.proxyEvent = null;
					ADN.onmousedown = ignore;
				};
				ADN.isIn = function(object) {
					if (!K.check.isElement(object)) {
						return false;
					}
					var Xmin = K.get.X(object);
					var Xmax = Xmin + object.offsetWidth;
					var Ymin = K.get.Y(object);
					var Ymax = Ymin + object.offsetHeight;
					var X = ADN.store.X;
					var Y = ADN.store.Y;
					return (Xmin < X && X < Xmax && Ymin < Y && Y < Ymax) ? true : false;
				};
				ADN.assign = function(object) {
                    var proxyEvent = object || ADN.cloneNode(true);
                    proxyEvent.store = ADN.store;
                    proxyEvent.event = ADN.event;
                    proxyEvent.drop = ADN.drop;
                    proxyEvent.isIn = ADN.isIn;
					proxyEvent.run = ADN.run;
                    ADN.proxyEvent = proxyEvent;
                    return ADN.proxyEvent;
				}
				ADN.event.mouseDown = function(event) {
					var event = event || window.event;
					ADN.run.drag.call({self: ADN, event: event});
					var Obj = ADN.proxyEvent || ADN;
					if (!(event.button == 2 || event.which == 3)) {
						var position = K.get.currentStyle(Obj, "position");
						Obj.style.position = (position != "absolute") ? "relative" : "absolute";
						var left = K.get.currentStyle(Obj, "left");
						Obj.style.left = parseInt(left) ? left : "0px";
						var top = K.get.currentStyle(Obj, "top");
						Obj.style.top = parseInt(top) ? top : "0px";
						Obj.store.x = event.clientX;
						Obj.store.y = event.clientY;
						Obj.event.mouseMove = function(event) {
							var event = event || window.event;
							Obj.style.left = parseInt(Obj.style.left) + (event.clientX - Obj.store.x) + "px";
							Obj.style.top = parseInt(Obj.style.top) + (event.clientY - Obj.store.y) + "px";
							Obj.store.x = event.clientX;
							Obj.store.y = event.clientY;
							Obj.store.X = K.get.X(event);
							Obj.store.Y = K.get.Y(event);
							Obj.run.move.call({self: Obj, event: event});
							return false;
						};
						Obj.event.mouseUp = function(event) {
							var event = event || window.event;
							document.onmousemove = null;
							document.onmouseup = null;
							Obj.onmouseup = null;
							Obj.event.mouseUp = null;
							Obj.event.mouseMove = null;
							Obj.run.drop.call({self: Obj, event: event});
							return false;
						};
						document.onmousemove = Obj.event.mouseMove;
						document.onmouseup = function(event) {
							var event = event || window.event;
							var S = K.get.eventSource(event);
							if (S != Obj) {
								document.onmousemove = null;
							}
							Obj.event.mouseUp(event);
						};
						Obj.onmouseup = Obj.event.mouseUp;
						return false;
					}
				};
				ADN.onmousedown = ADN.event.mouseDown;
				function ignore(event) {
					var event = event || window.event;
					event.cancelBubble = true;
				}
				function ignoreDagDrop(group) {
					if (group && group.length) {
						for (var o = 0; o < group.length; ++ o) {
							group[o].onmousedown = function(event) {
								var event = event || window.event;
								event.cancelBubble = true;
							}
						}
					}
				}
				(function() {
					var aForm = ADN.getElementsByTagName("form");
					if (aForm && aForm.length) {
						ignoreDagDrop(aForm);
					} else {
						var aInput = ADN.getElementsByTagName("input");
						ignoreDagDrop(aInput);
						var aIframe = ADN.getElementsByTagName("iframe");
						ignoreDagDrop(aIframe);
						var aTextarea = ADN.getElementsByTagName("textarea");
						ignoreDagDrop(aTextarea);
					}
				})();
				return K({Element: ADN});
			};
		}
		try {
			return E;
		} finally {
			E = null;
		}
	};
	/**
	 * Add style, event, class, child node, attribute for an element node;
	 * @param {JSON object} r
	 * Example:
	 * 		var kombai = K('kombai');
	 * 		K.add({
	 * 			element: kombai,
	 * 			event: {
	 * 				click: function() {
	 * 					alert('click');
	 * 				}
	 * 			}
	 * 		});
	 * 		//this is same code:
	 * 		K('kombai').add({
	 * 			event: {
	 * 				click: function() {
	 * 					alert('click');
	 * 				}
	 * 			}
	 * 		});
	 */
	K.add = function(r) {
		var setting = {
			element: null,
			className: null,
			style: null,
			event: null,
			attribute: null,
            childNode: null
		};
		for (var o in setting) {
			if (!Object.prototype[o] && r[o] !== undefined) {
				setting[o] = r[o];
			}
		}
		(function () {
			with (setting) {
				if (!element) {
					return;
				}
				if (className != null) {
					addClassName(element, className);
				}
				if (style != null) {
					addStyle(element, style);
				}
				if (event != null && event instanceof Object) {
					addEvent(element, event);
				}
				if (attribute != null && attribute instanceof Object) {
					addAttribute(element, attribute);
				}
                if (childNode != null) {
					addChild(element, childNode);
				}
			}
		})();
		function addClassName(e, c) {
			var eC = e.className;
			eC = (eC != "") ? eC += " " + c : c;
		}
		function addStyle(e, s) {
			if ((/string/).test(typeof s)) {
				e.setAttribute("style", s);
			} else if (s.constructor == Object) {
				var st = e.style;
                for (var o in s) {
					if (o == 'float') {
                        st['cssStyle'] = s[o];
                        st['styleFloat'] = s[o];
                    } else {
                        st[o] = s[o];
                    }
				}
			}
		}
		function addEvent(e, evt) {
			for (var o in evt) {
				if (!Object.prototype[o]) {
					if (e.addEventlistenerer) {
			            e.addEventlistenerer(o, evt[o], false);
			        } else if (e.attachEvent) {
			            e.attachEvent("on" + o, evt[o]);
			        } else {
						e["on" + o] = evt[o];
					}
				}
			}
		}
		function addAttribute(e, a) {
			for (var o in a) {
				if (!Object.prototype[o]) {
					e.setAttribute(o.toString(), a[o]);
				}
			}
		}
        function addChild(e, c) {
            e.appendChild(c);
        }
	};

	K.get = {
		/**
		 * Returns an unique string;
		 * Example:
		 * 		alert(K.get.generalId());
		 * 		alert(K.get.generalId());
		 */
		generalId: function() {
			return new Date().getTime() + Math.random().toString().substring(2);
		},
		/**
		 * Returns the name of browser;
		 * Example:
		 * 		alert(K.get.browserName());
		 */
		browserName: function() {
			return navigator.appName;
		},
		/**
		 * Return the domain of address;
		 * Example:
		 * 		alert(K.get.domain());
		 */
		domain: function() {
			return document.domain;
		},
		/**
		 * Returns the range object;
		 */
		range: function() {
			var selection = (window.getSelection) ?
								window.getSelection() : document.selection;
			return selection ?
					(selection.rangeCount > 0) ?
						selection.getRangeAt(0) : selection.createRange() : null;
		},
		/**
		 * Returns the text has been selected by the mouse;
		 */
		selection: function() {
			return (window.getSelection) ?
						window.getSelection() : document.selection.createRange().text;
		},
		/**
		 * Return true height of element node;
		 * @param {String} r
		 * Example:
		 * 		alert(K.get.height('kombai'));
		 * 		//other code:
		 * 		alert(K.get.height(K('kombai')));
		 */
		height: function(r) {
			var dg = document.getElementById;
			var e = (/string/).test(typeof r) ? dg(r) : r;
			return (e.height !== undefined) ? e.height : e.offsetHeight;
		},
		/**
		 * Return true with of element node;
		 * @param {String} r
		 * Example:
		 * 		alert(K.get.with('kombai'));
		 * 		//other code:
		 * 		alert(K.get.with(K('kombai')));
		 */
		width: function(r) {
			var dg = document.getElementById;
			var e = (/string/).test(typeof r) ? dg(r) : r;
			return (e.width !== undefined) ? e.width : e.offsetWidth;
		},
		/**
		 * Returns the height of the window;
		 */
		windowHeight: function() {
			var w = window,
			d = document,
			iH = "innerHeight",
			cH = "clientHeight",
			dE = "documentElement";
			return (w[iH] !== undefined) ? w[iH] : d[dE] ? d[dE][cH] : d.body[cH];
		},
		/**
		 * Returns the with of the window;
		 */
		windowWidth: function() {
			var w = window,
			d = document,
			iW = "innerWidth",
			cW = "clientWidth",
			dE = "documentElement";
			return (w[iW] !== undefined) ? w[iW] : d[dE] ? d[dE][cW] : d.body[cW];
		},
		/**
		 * Returns the height of page site;
		 */
		pageHeight: function() {
			return document.body.scrollHeight;
		},
		/**
		 * Returns the width of page site;
		 */
		pageWidth: function() {
			return document.body.scrollWidth;
		},
		/**
		 * Returns value of style attribute of an element node;
		 * @param {Element node} e
		 * @param {String} p
		 * Example:
		 * 		K('kombai').opacity(64);
		 * 		alert(K.get.currentStyle(K('kombai'), 'opacity'));
		 * 		//alerts 64;
		 */
		currentStyle: function(e, p) {
			var s,
			d = document,
			dV = "defaultView",
			gCS = "getComputedStyle",
			gPV = "getPropertyValue";
			var rgb = function(r, g, b) {
				return "#" + (65536*r + 256*g + b).toString(16);
			}
			if (e.currentStyle) {
				if (p == "opacity") {
					var v = e.currentStyle["filter"];
					var m = v.match(/(.*)opacity\s*=\s*(\w+)(.*)/i);
					if (m) {
						s = parseFloat(m[2]);
						return isNaN(r) ? 100 : s;
					}
					return 100;
				}
				return e.currentStyle[p];
			} else if (d[dV] && d[dV][gCS]) {
				p = p.replace(/[(A-Z)]/g, function(match){return "-" + match.toLowerCase()});
				s = d[dV][gCS](e, null)[gPV](p);
				return (/rgb\(.+\)/).test(s) ? eval(s) : (p == "opacity") ? s*100 : s;
			}
		},
		/**
		 * Returns the current time() by minisecond;
		 */
		currentTime: function() {
			return new Date().getTime();
		},
		/**
		 * Returns the element node just has event;
		 * @param {Event } event
		 */
		eventSource: function(event) {
			return (event && event.target) ? event.target : window.event.srcElement;
		},
		/**
		 * Returns distance from element node or event object to the left edge of view area;
		 * @param {Event or Id String} r
		 * Example:
		 * 		document.onmousemove = function(event) {
		 * 			document.title = K.get.X(event);
		 * 		}
		 *
		 * 		alert(K.get.X('kombai'));
		 */
		X: function(r) {
			var d = document, dE = "documentElement", gE = "getElementById";
			var e = (/string/).test(typeof r) ? d[gE](r) : r ? r : window.event;
			if (e.nodeName) {
				var x = 0;
				while (e) {
					x += e.offsetLeft;
					e = e.offsetParent;
				}
				return x;
			} else if (e.clientX !== undefined) {
				return (e.clientX + d.body.scrollLeft + d[dE].scrollLeft);
			}
		},
		/**
		 * Returns distance from element node or event object to the top edge of view area;
		 * @param {Event or Id String} r
		 * Example:
		 * 		document.onmousemove = function(event) {
		 * 			document.title = K.get.Y(event);
		 * 		}
		 *
		 * 		alert(K.get.Y('kombai'));
		 */
		Y: function(r) {
			var d = document, dE = "documentElement", gE = "getElementById";
			var e = (/string/).test(typeof r) ? d[gE](r) : r ? r : window.event;
			if (e && e.nodeName) {
				var y = 0;
				while (e) {
					y += e.offsetTop;
					e = e.offsetParent;
				}
				return y;
			} else if (e.clientY !== undefined) {
				return (e.clientY + d.body.scrollTop + d[dE].scrollTop);
			}
		},
		/**
		 * Returns the first child (element node) of Element node if it exists, returns null if it not exists;
		 * @param {Element node} r
		 */
		firstChild: function(r) {
			var f = null,
			d = document,
			tN = "tagName",
			fC = "firstChild",
			nS = "nextSibling",
			gE = "getElementById";
			var e = (/string/).test(typeof r) ? d[gE](r) : r;
			if (e && e.nodeName) {
				f = e[fC];
				while(f && f.nodeType != 1) {
					f = f[nS];
				}
			}
			return f;
		},
		/**
		 * Returns the last child (element node) of Element node if it exists, returns null if it not exists;
		 * @param {Element node} r
		 */
		lastChild: function(r) {
			var l = null,
			d = document,
			tN = "tagName",
			lC = "lastChild",
			pS = "previousSibling",
			gE = "getElementById";
			var e = (/string/).test(typeof r) ? d[gE](r) : r;
			if (e && e.nodeName) {
				l = e[lC];
				while(l && l.nodeType != 1) {
					l = l[pS];
				}
			}
			return l;
		},
		/**
		 * Returns the next element in DOM of Element node if it exists, returns null if it not exists;
		 * @param {Element node} r
		 */
		nextElement: function(r) {
			var n = null,
			d = document,
			tN = "tagName",
			nS = "nextSibling",
			gE = "getElementById";
			var e = (/string/).test(typeof r) ? d[gE](r) : r;
			if (e && e.nodeName) {
				n = e[nS];
				while(n && n.nodeType != 1) {
					n = n[nS];
				}
			}
			return n;
		},
		/**
		 * Returns the previous element in DOM of Element node if it exists, returns null if it not exists;
		 * @param {Element node} r
		 */
		previousElement: function(r) {
			var p = null,
			d = document,
			tN = "tagName",
			pS = "previousSibling",
			gE = "getElementById";
			var e = (/string/).test(typeof r) ? d[gE](r) : r;
			if (e && e.nodeName) {
				p = e[pS];
				while(p && p.nodeType != 1) {
					p = p[pS];
				}
			}
			return p;
		}
	};

	K.set = {
		/**
		 * Extend of function window.setTimeout;
		 * @param {JSON object} r
		 * Example:
		 * 		function run() {
		 * 			alert(new Date());
		 * 		}
		 * 		//this code will alerts three times in 6 second;
		 * 		K.set.timeout({
		 * 			method: run,
		 * 			delay: 2000,
		 * 			amount: 3
		 * 		});
		 *
		 * 		//more options please see in variable 'setting';
		 */
		timeout: function(r) {
			var setting = {
				method: function() {},
				begin: function() {},
				delay: 1000,
				param: [],
				until: function() {
					return false;
				},
				amount: 4294967295,
				release: function() {}
			};
			var n = 0;
			for (var o in setting) {
				if (!Object.prototype[o] && r[o]) {
					setting[o] = r[o];
				}
			}
			function repeat() {
				if (setting && !setting.until() && (n < setting.amount)) {
					setting.method.apply(setting.method, setting.param);
					setTimeout(repeat, setting.delay);
					++ n;
				} else {
					setting.release();
					setting = null;
				}
			};
			setTimeout(repeat, setting.delay);
			setting.begin();
		},
		/**
		 * Using to restore a range object;
		 * @param {JSON object} r
		 */
		range: function(r) {
			var setting = {
				range: null,
				selection: null
			}
			for (var o in setting) {
				if (!Object.prototype[o] && r[o]) {
					setting[o] = r[o];
				} else {
					return;
				}
			}
			if (window.getSelection) {
				setting.selection.removeAllRanges();
				setting.selection.addRange(setting.range);
			} else {
				setting.range.select();
			}
		}
	};

	K.check = {
		/**
		 * Returns true if browser is Safari;
		 */
		isSafari: function() {
			return (/Safari/).test(navigator.userAgent);
		},
		/**
		 * Returns true if browser is Opera;
		 */
		isOpera: function() {
			return (/Opera/).test(navigator.userAgent);
		},
		/**
		 * Returns true if browser is Firefox;
		 */
		isFF: function() {
			return (/Firefox/).test(navigator.userAgent);
		},
		/**
		 * Returns true if browser is Internet Explorer;
		 */
		isIE: function() {
			return (/MSIE/).test(navigator.userAgent);
		},
		/**
		 * Returns true if browser is Internet Explorer version 6;
		 */
		isIE6: function() {
			return (/MSIE 6/).test(navigator.userAgent);
		},
		/**
		 * Returns true if browser is Internet Explorer version 7;
		 */
		isIE7: function() {
			return (/MSIE 7/).test(navigator.userAgent);
		},
		/**
		 * Returns true if browser is Internet Explorer version 8;
		 */
		isIE8: function() {
			return (/MSIE 8/).test(navigator.userAgent);
		},
		/**
		 * Returns true if the param passed in is Function;
		 * @param {Object} r
		 */
		isFunction: function(r) {
			return (r != null && r.constructor == Function);
		},
		/**
		 * Returns true if the param passed in is String;
		 * @param {Object} r
		 */
		isString: function(r) {
			return (r && (/string/).test(typeof r));
		},
		/**
		 * Returns true if the param passed in is Number;
		 * @param {Object} r
		 */
		isNumber: function(r) {
			return (r != null && r.constructor == Number);
		},
		/**
		 * Returns true if the param passed in is Array;
		 * @param {Object} r
		 */
		isArray: function(r) {
			return (r != null && r.constructor == Array);
		},
		/**
		 * Returns true if the param passed in is Regular Expression;
		 * @param {Object} r
		 */
		isRegExp: function(r) {
			return (r != null && r.constructor == RegExp);
		},
		/**
		 * Returns true if the param passed in is Object not is Element node;
		 * @param {Object} r
		 */
		isObject: function(r) {
			return (r != null && r instanceof Object);
		},
		/**
		 * Returns true if the param passed in is Element node;
		 * @param {Object} r
		 */
		isElement: function(r) {
			return (r && r.tagName && r.nodeType == 1);
		}
	};

	K.remove = {
		/**
		 * Removes the element passed in from DOM;
		 * @param {Element node} r
		 * Example:
		 * 		K.remove.element(K('kombai'));
		 */
		element: function(r) {
			var p = "parentNode",
			rC = "removeChild",
			dg = document.getElementById;
			var e = (/string/).test(typeof r) ? dg(r) : r;
			(r && r[p]) ? r[p][rC](r) : false;
		},
		/**
		 * Implements trim method;
		 * @param {String} r
		 */
		space: function(r) {
			return (/string/).test(typeof r) ? r.replace(/^\s+|\s+$/g, "") : "";
		},
		/**
		 * Implements trip tag method;
		 * @param {Object} r
		 */
		tag: function(r) {
			return (/string/).test(typeof r) ? r.replace(/<\/?[^>]+>/gi, "") : "";
		},
		/**
		 * Removes timeout has been set by window.setTimeout or window.setInterval;
		 * @param {Object} r
		 */
		timeout: function(r) {
			clearInterval(r);
			clearTimeout(r);
		}
	};

	K.create = {
		/**
		 * This is the main idea of program, using to manages JSON object with SQL syntax;
		 * @param {JSON object} r
		 * Example:
		 * 		//create a new database
		 *		var mydata = K.create.database({
		 *		 	fieldName: ["name", "phone"],
		 *			primaryKey: "phone"
		 *		});
		 *		// insert in to database
		 *		mydata.Insert(["ohay", "0987654321"]);
		 *		mydata.Insert(["oh", "0987654322"]);
		 *		mydata.Insert(["ha", "0987654323"]);
		 *		mydata.Insert(["hy", "0987654324"]);
		 *
		 *		mydata.Insert({"phone" : "0987654324", "name” : "hy"});
		 *		mydata.Insert({"phone" : "0987654325", "name" : "yo"});
		 *
		 *		//update
		 *		mydata.Update({"phone" : "232093430", where: "name like 'o%'"});
		 *		mydata.Update({"name": "none", where: "phone == '0987654325'"});
		 *
		 *		//select
		 *		mydata.Select({fieldName: "phone", where: "name like '%o%'", orderBy: "phone", Limit: 3});
		 *
		 *		//delete
		 *		mydata.Delete({Where: "name == 'ohay'"});
		 *
		 *		//drop database:
		 *		mydata.Drop();
		 *
		 *		//create from a collection;
		 * 		vnjs.data = K.create.database({
		 * 				fromCollection:[
		 * 					{id:2,title:"Fontyukle",code:"fontyukle"},
		 * 					{id:6,title:"Full text search",code:"full text search"},
		 * 					{id:56,title:"Helloworld extension",code:"helloworld extension"},
		 * 					{id:57,title:"FFont",code:"ffont"},
		 * 					{id:58,title:"Sadf",code:"sadf"},
		 * 					{id:59,title:"Dragdrop demo",code:"dragdrop demo"}
		 * 				]
		 * 		});
		 *
		 * 		//more options please see in 'setting' varialbe;
		 */
		database: function(r) {
			return new function() {
				if (!(/object/).test(typeof r)) {
					alert("Don't create database");
					return;
				}
				//config database;
				var reference = "7c4bc080af27ded752b36160dcb1c716";
				var ADN = this;
				var setting = {
					fromCollection: null,
					fieldName: [],
					primaryKey: null,
					autoIncrement: null,
					ignoreError: false
				};
				for (var o in setting) {
					if (!Object.prototype[o] && r[o]) {
						setting[o] = r[o];
					}
				}
				setting.rowIndex = 0;
				setting.stepJump = 1;
				setting.startRange = 1;
				if (!setting.fromCollection) {
					ADN.Row = [];
					//check config database;
					if (!setting.fieldName ||
							setting.fieldName.constructor != Array ||
								!setting.fieldName.length) {
						alert("fieldName is not null");
						return;
					} else if (setting.primaryKey) {
						var checkPrimaryKey = false;
						var length = setting.fieldName.length;
						for (var o = 0; o < length; ++ o) {
							if (setting.primaryKey == setting.fieldName[o]) {
								checkPrimaryKey = true;
								break;
							}
						}
						if (!checkPrimaryKey) {
							if (!setting.ignoreError) {
								alert("please preview primaryKey");
							}
							return false;
						}
					}
					//setting for autoIncrement field;
					if (setting.autoIncrement != null && setting.autoIncrement.constructor == Array) {
						if (setting.autoIncrement[1] && setting.autoIncrement[1] instanceof Object) {
							var range = setting.autoIncrement[1];
							setting.startRange = (range.start !== undefined &&
													range.start.constructor == Number) ?
														range.start : setting.startRange;
							setting.stepJump = (range.step !== undefined &&
													range.step.constructor == Number) ?
														range.step : setting.stepJump;
						}
						setting.autoIncrement = setting.autoIncrement[0];
					}
					//check autoIncrement key;
					if (setting.autoIncrement) {
						var checkAutoIncrement = false;
						for (var o in setting.fieldName) {
							if (setting.autoIncrement == setting.fieldName[o]) {
								checkAutoIncrement = true;
								break;
							}
						}
						if (checkAutoIncrement) {
							setting.fieldName.splice(o, 1);
							setting.fieldName.push(setting.autoIncrement);
						} else {
							if (!setting.ignoreError) {
								alert("please preview autoIncrement key");
							}
							return false;
						}
					}
				} else {
					ADN.Row = setting.fromCollection;
					with (setting) {
						if (fromCollection.length) {
							rowIndex = fromCollection.length - 1;
						} else {
							if (!ignoreError) {
								alert("fromCollection is not empty");
							}
							return false;
						}
						stepJump = 1;
						startRange = 1;
						fieldName = null;
						primaryKey = null;
						autoIncrement = null;
					}
				}// end config database;

				ADN.Drop = function() {
					ADN.Row = [];
					with (setting) {
						rowIndex = 0;
						stepJump = 1;
						startRange = 0;
					}
				}

				ADN.Count = function() {
					return ADN.Row.length;
				}

				ADN.Check = function(content) {
					if (!content.condition) {
						return false;
					} else {
						content.condition = parseCondition(content.condition);
					}
					for (var o in ADN.Row) {
						with (ADN.Row[o]) {
							if (eval(content.condition)) {
								return true;
							}
						}
					}
					return false;
				}//end method Check;

				ADN.Insert = function(data) {
					if (!data && data.constructor && data.constructor != Object) {
						if (!setting.ignoreError) {
							alert("Can't insert value into table");
						}
						return;
					}
					// create mask element;
					var size = setting.fieldName.length;
					if (size) {
						var newObject = {};
						for (var o = 0; o < size; ++ o) {
							if (!setting.autoIncrement || (setting.fieldName[o] != setting.autoIncrement)) {
								var cellValue = (data[o] != null) ? data[o] : data[setting.fieldName[o]];
								newObject[setting.fieldName[o]] = (cellValue != null) ? cellValue : null;
							} else if (setting.fieldName[o] == setting.autoIncrement) {
								var checkAutoValue = (data[o] != null) ?
														data[o] : data[setting.fieldName[o]];
								if ((checkAutoValue != null) && (checkAutoValue != setting.startRange)) {
									if (!setting.ignoreError) {
										alert(
											"cannot insert value = " +
											checkAutoValue +
											" in to autoIncrement field " +
											setting.autoIncrement
										);
									}
									return;
								} else {
									newObject[setting.fieldName[o]] = setting.startRange;
									setting.startRange += setting.stepJump;
								}
							}
						}
						//check unique value;
						size = ADN.Count();
						for (var o = 0; o < size; ++ o) {
							if (setting.primaryKey === null || setting.primaryKey == "") {
								break;
							} else if (ADN.Row[o][setting.primaryKey] == newObject[setting.primaryKey]) {
								if (!setting.ignoreError) {
									alert(
										"value of primary key '" +
										setting.primaryKey +
										"' : " +
										newObject[setting.primaryKey] +
										" has exits in row : " + o
									);
								}
								return;
							}
						}//end check;
					} else {
						var newObject = data;
					}
					// create new record;
					ADN.Row[setting.rowIndex] = newObject;
					setting.rowIndex += 1;
				}//end method Insert;

				ADN.Select = function(condition) {
					var noneCondition = (condition == undefined || condition.constructor != Object);
					var config = {
						fieldName : setting.fieldName,
						where : null,
						limit: ADN.Row.length,
						orderBy : null,
						formatWith: null
					};
					config.begin = 0;
					config.mask = [];
					var data = [];
					if (noneCondition) {
						data = ADN.Row;
					} else {
						for (var o in config) {
							if (condition[o]) {
								config[o] = condition[o];
							}
						}
						for (var o in ADN.Row) {
							config.mask[o] = ADN.Row[o];
						}
						config.where = parseCondition(config.where);
						parseLimitClause();
						parseOrderByClause();
						data = selectData();
					}
					//return result;
					return data;

					/*
					*	private function;
					*	parseLimitClause;
					*	parseOrderByClause;
					*	selectData;
					*/
					function parseLimitClause() {
						if (config.limit.constructor == Array) {
							config.begin = config.limit[0];
							config.limit = config.limit[1];
						}
					}//end function parseLimitClause;
					function parseOrderByClause() {
						if (config.orderBy === null) {
							return;
						}
						var order = [];
						if (config.orderBy.indexOf(",") > 0) {
							order = config.orderBy.split(",");
						} else 	{
							order[0] = config.orderBy;
						}
						//input : orderBy : "a+b+c ASC, d DESC";
						var length = order.length;
						for (var o = 0; o < length; ++ o) {
							var head = order.slice(0, o);
							var foot = order.slice(o, order.length);
							if (order[o].indexOf("+") > 0) {
								var body = order[o].split("+");
								var end = body[body.length - 1];
								var regExp = new RegExp("\\b(\\w+)\\b(.*)\\b","i");
								if (regExp.test(end)) {
									reg = regExp.exec(end);
									body[body.length - 1] = reg[1];
									reg[2] = (reg[2] == "") ? "asc" : reg[2];
									for (var i = 0; i < body.length; i ++ ) {
										body[i] = body[i] + " " + reg[2];
									}
								}
								//remove the last of foot;
								foot.splice(0, 1);
								//build the array order;
								order = head.concat(body).concat(foot);
							}
						}
						//output : a ASC, b ASC, c ASC, d DESC;
						for (var o = 0; o < length; ++ o) {
							var clause = [];
							for (var i = 0; i <= o; ++ i) {
								isOrder = new RegExp("\\b(\\w+)\\b(.*)\\b","i");
								if (isOrder.test(order[i])) {
									reg = isOrder.exec(order[i]);
									if (reg[2].toLowerCase().indexOf("desc") > -1) {
										clause.push("(current." + reg[1] + " <= next." + reg[1] + ")");
									} else if (reg[2].toLowerCase().indexOf("asc") > -1 || reg[2] == "") {
										clause.push("(current." + reg[1] + " >= next." + reg[1] + ")");
									}
								}
							}
							clause = clause.join("&&");
							var depository = {};
							var current = {};
							var next = {};
							var size = config.mask.length;
							for (var current = 0; current < size; ++ current) {
								for (var next = eval(current + 1); next < size; ++ next) {
									current = config.mask[current];
									next = config.mask[next];
									if (eval(clause)) {
										depository = config.mask[current];
										config.mask[current] = config.mask[next];
										config.mask[next] = depository;
									}
								}
							}
						}
					}//end function parseOrderByClause;
					function selectData() {
						var result = [];
						var iiii = 0;
						var size = config.mask.length;
						for (var element = config.begin; element < size && iiii < config.limit; ++ element) {
							if (config.mask[element]) {
								with (config.mask[element]) {
									if (eval(config.where)) {
										if (setting.fromCollection) {
											result[iiii] = config.mask[element];
										} else {
											var nWidth = config.fieldName.length;
											result[iiii] = {};
											for (var column = 0; column < nWidth; ++ column) {
												result[iiii][config.fieldName[column].toString()] = config.mask[element][config.fieldName[column].toString()];
											}
										}
										if (config.formatWith && config.formatWith instanceof Function) {
											result[iiii] = config.formatWith(result[iiii], iiii);
										}
										iiii ++;
									}
								}
							}
						}
						return result;
					}

					/*
					*	end private function;
					*/
				}//end method Select;

				ADN.Delete = function(condition) {
					var where = condition.where ? parseCondition(condition.where) : null;
					for (var o in ADN.Row) {
						if (Array.prototype[o]) {
							continue;
						}
						with (ADN.Row[o]) {
							if (eval(where)) {
								ADN.Row.splice(o, 1);
								setting.rowIndex -= 1;
							}
						}
					}
				}//end method Delete;

				ADN.Update = function(data) {
					var config = {
						rowSet : {},
						where : false
					};
					for (var o in data) {
						if (o == "where") {
							config.where = data.where;
							config.where = parseCondition(config.where);
						} else if (!Object.prototype[o]) {
							config.rowSet[o] = data[o];
						}
					}
					//check value of primary key;
					var length = ADN.Count();
					for (var o = 0; o < length; ++ o) {
						for (var delta in config.rowSet) {
							if (delta == setting.primaryKey) {
								if (ADN.Row[o][delta] == config.rowSet[delta]) {
									if (!setting.ignoreError) {
										alert(
											"value of primary key '" +
											delta +
											"' : " +
											config.rowSet[delta] +
											", it has exits in row : " + o
										);
									}
									return;
								}
							}
						}
					}
					var checkCondition = false;
					for (var o = 0; o < length; ++ o) {
						// check condition;
						checkCondition = false;
						with (ADN.Row[o]) {
							if (eval(config.where)) {
								checkCondition = true;
							}
						}
						//update value to record;
						if (checkCondition) {
							for (var delta in config.rowSet) {
								if (delta == setting.autoIncrement)	{
									if (config.rowSet[delta] != ADN.Row[o][delta]) {
										if (!setting.ignoreError) {
											alert(
												"cannot update value = " +
												config.rowSet[delta] +
												" in to autoIncrement field : " +
												setting.autoIncrement
											);
										}
										return;
									}
								} else {
									ADN.Row[o][delta] = config.rowSet[delta];
								}
							}
						}
					}// end the loop;
					return false;
				}//end method Update;

				/*
				*	private methods;
				*	parseCondition;
				*	Between;
				*	Like;
				*/
				function parseCondition(condition) {
					condition = Between(Like(condition));
					return condition ? condition : 1;
				}
				function Between(condition) {
					var notBetween = new RegExp("^\\s*(.+)\\s+(not between)\\s+(.*)\\s+(and)\\s+(.*)\\s*$","i");
					var isBetween = new RegExp("^\\s*(.+)\\s+(between)\\s+(.*)\\s+(and)\\s+(.*)\\s*$","i");
					if (notBetween.test(condition)) {
						var match = notBetween.exec(condition);
							match[3] = eval(match[3]);
							match[5] = eval(match[5]);
						if ((/string/).test(typeof match[3])) {
							match[3] = "'" + match[3] + "'";
						}
						if ((/string/).test(typeof match[5])) {
							match[5] = "'" + match[5] + "'";
						}
						if (match[3] > match[5]) {
							var depository = match[3];
							match[3] = match[5];
							match[5] = depository;
						}
						return "(" + match[3] + " > " + match[1] + ") || (" + match[1] + " > " + match[5] + ")";
					} else if (isBetween.test(condition)) {
						var match = isBetween.exec(condition);
							match[3] = eval(match[3]);
							match[5] = eval(match[5]);
						if ((/string/).test(typeof match[3])) {
							match[3] = "'" + match[3] + "'";
						}
						if ((/string/).test(typeof match[5])) {
							match[5] = "'" + match[5] + "'";
						}
						if (match[3] > match[5]) {
							var depository = match[3];
							match[3] = match[5];
							match[5] = depository;
						}
						return "(" + match[3] + " < " + match[1] + ") && (" + match[1] + " < " + match[5] + ")";
					} else {
						return condition;
					}
				}
				function Like(condition) {
					var notLike = new RegExp("^\\s*(.+)\\s+(not like)\\s*(')\\s*(.*)\\s*(')\\s*$", "i");
					var isLike = new RegExp("^\\s*(.+)\\s+(like)\\s*(')\\s*(.*)\\s*(')\\s*$", "i");
					var reject = /^\s+|\s+$/ ;
					var like = false;
					if (notLike.test(condition)) {
						var match = notLike.exec(condition);
						var isFalse = " == ";
						var isTrue = " != ";
						like = true;
					} else if (isLike.test(condition)) {
						var match = isLike.exec(condition);
						var isFalse = " != ";
						var isTrue = " == ";
						like = true;
					}
					if (like) {
						match[1] = match[1].toString();
						match[4] = match[4].toString();
						match[1] = match[1].replace(reject, "");
						match[4] = match[4].replace(reject, "");
						var regFull = /^%(.*)%$/;
						var regLeft = /^%(.*)/;
						var regRight = /(.*)%$/;
						if (regFull.test(match[4])) {
							match[4] = regFull.exec(match[4])[1];
							return (match[1] + ".toString().indexOf('" + match[4] + "')" + isFalse + "-1");
						} else if (regLeft.test(match[4])) {
							match[4] = regLeft.exec(match[4])[1];
							return (match[1] + ".toString().lastIndexOf('" + match[4] + "')" + isTrue + "(" + match[1] + ".length - " + match[4].length + ")");
						} else if (regRight.test(match[4])) {
							match[4] = regRight.exec(match[4])[1];
							return (match[1] + ".toString().indexOf('" + match[4] + "')" + isTrue + "0");
						} else {
							return (match[1] + isTrue + "'" + match[4] + "'");
						}
					} else {
						return condition;
					}
				}

				/*
				* end private methods;
				*/
			}// end class;
		},
		/**
		 * Using to create dynamic element node;
		 * @param {JSON object} r
		 * Example:
		 * 		//create default element;
		 * 		var div = K.create.element({
		 * 			innerHTML: 'div element'
		 * 		});
		 *
		 * 		//create with general id;
		 * 		var div = K.create.element({
		 * 			innerHTML: 'hi',
		 * 			id: K.get.generalId()
		 * 		});
		 *
		 * 		//create with event and attribute;
		 * 		var a = K.create.element({
		 * 			style: "font-size: 12px; font-weight: bold",
		 * 			tagName: 'a',
		 * 			innerHTML: 'click me',
		 * 			attribute: {
		 * 				href: 'javascript: void(0)',
		 * 				title: 'hi'
		 * 			},
		 * 			event: {
		 * 				click: function() {
		 * 					alert('click click');
		 * 				},
		 * 				mouseout: function() {
		 * 					alert('mouse out');
		 * 				}
		 * 			}
		 *
		 * 		});
		 */
		element: function(r) {
			var setting = {
				tagName: "div",
				id: null,
				innerHTML: null,
				className: null,
				//K.add;
				event: null,
				style: null,
				attribute: null
			};
			for (var o in setting) {
				if (!Object.prototype[o] && r[o] != undefined) {
					setting[o] = r[o];
				}
			}
			var newNode = document.createElement(setting.tagName);
			if (setting.id) {
				newNode.id = setting.id;
			}
			if (setting.innerHTML) {
				newNode.innerHTML = setting.innerHTML;
			}
			if (setting.className) {
				newNode.className = setting.className;
			}
			//working with K.add;
			if (K.add && K.add instanceof Function) {
				K.add({
					element: newNode,
					event: setting.event,
					style: setting.style,
					attribute: setting.attribute
				});
			}
			return newNode;
		}
	};
	/**
	 * Implements function insertAdjacentHTML of IE;
	 * @param {JSON object} r
	 * Example:
	 * 		K.insert({
	 * 			element: document.getElementById('login-form'),
	 * 			refer: document.getElementById('kombai'),
	 * 			where: 'beforeEnd'
	 * 		});
	 *
	 * 		//same code:
	 * 		K('kombai').insert({
	 * 			element: K('login-form'),
	 * 			where: 'beforeEnd'
	 * 		});
	 */
	K.insert = function(r) {
		var setting = {
			element: document.createElement("div"),
			refer: document.body,
			where: "beforeEnd"
		};
		for (var o in setting) {
			if (!Object.prototype[o] && r[o]) {
				setting[o] = r[o];
			}
		}
		with (setting) {
			if ((/beforeBegin/i).test(where)) {
				refer.parentNode.insertBefore(element, refer);
			} else if ((/afterBegin/i).test(where)) {
				setting.refer.insertBefore(element, refer.firstChild);
			} else if ((/beforeEnd/i).test(where)) {
				refer.appendChild(element);
			} else if ((/afterEnd/i).test(where)) {
				refer.parentNode.insertBefore(element, refer.nextSibling);
			}
		}
	};
	/**
	 * Returns an array of Element nodes with specified clause;
	 * @param {JSON object} r
	 * Example:
	 * 		//gets all images has title is 'copyright uoon' in 'kombai' node;
	 * 		var imgs = K.select({
	 * 			from: document.getElementById('kombai'),
	 * 			where: "tagName =='IMG' && title == 'copyright uoon'"
	 * 		});
	 *
	 * 		//Implements funciton getElementsByClassName;
	 * 		function getElemenetsByClassName(id, clazz) {
	 * 			var root = document.getElementById(root);
	 * 			if (!root) {
	 * 				return null;
	 * 			}
	 * 			return K.select({
	 * 				from: root,
	 * 				where: "className like '%" + clazz + "%'"
	 * 			});
	 * 		}
	 */
	K.select = function(r) {
		var setting = {
			from: document,
			where: null,
			formatWith: null
		};
		for (var o in setting) {
			if (!Object.prototype[o] && r[o]) {
				setting[o] = r[o];
			}
		}
		var DOM = null;
		if (setting.from && setting.from.constructor == Array) {
			DOM = K.create.database({fromCollection: setting.from});
		} else {
			var tree = setting.from.getElementsByTagName("*");
			if (tree && tree.length) {
				var size = tree.length;
				var collection = [];
				for (var o = 0; o < size; ++ o) {
					collection.push(tree[o]);
				}
				if (collection.length) {
					DOM = K.create.database({fromCollection: collection});
				}
			}
		}
		if (DOM && DOM.Select) {
			return DOM.Select({where: setting.where, formatWith: setting.formatWith});
		}
		return null;
	};
	/**
	 * Using to cache ajax;
	 */
	Kombai.archive.data = {
		oldRequest: K.create.database({
			fieldName : ["compare", "responseText", "responseXML"],
			primaryKey: "compare",
			ignoreError: true
		})
	};

	/**
	 * Working with ajax request;
	 * @param {JSON object} r
	 * Example:
	 * 		K.request({
	 * 			address: 'http://example.com',
	 * 			method: 'post',
	 * 			data: 'action=get&object=demo',
	 * 			onSuccess: function() {
	 * 				alert(this.responseText);
	 * 			}
	 * 		});
	 *
	 * 		//using cache option,
	 * 		//when using this option, the program will store parame and data response;
	 * 		K.request({
	 * 			address: 'http://example.com',
	 * 			method: 'post',
	 * 			cache: true,
	 * 			data: 'action=get&object=demo',
	 * 			onSuccess: function() {
	 * 				alert(this.responseText);
	 * 			},
	 * 			onFailure: function() {
	 * 				alert("can't connect with server, please try again !");
	 * 			}
	 * 		});
	 *
	 * 		//more option please see in 'setting' variable;
	 */
	K.request = function(r) {
		var oldRequest = Kombai.archive.data.oldRequest;
		if (!r || r.constructor != Object) {
			return;
		}
		var enkode = function(s) {
			if (s === null || s == undefined) {
				s = "|";
			}
			var l = s.length, a = [];
			for (var i = 0; i < l; ++ i) {
				a.push(s.charCodeAt(i));
			}
			return a.join("");
		};
		return new function() {
			this.request = false;
			var self = this;
			var xhr = {};
			var	code = "";
			var setting =  {
				address: null,
				async: true,
				data: null,
				delay: 1000,
				method: "POST",
				retry: 0,
				onAbort: null,
				onFailure: null,
				onRequest: null,
				onSuccess: null
			};
			var cache = r.cache || false;
			for (var o in setting) {
				if (!Object.prototype[o] && r[o]) {
					setting[o] = r[o];
				}
			}
			var amount = r.reload ? setting.retry - r.reload : setting.retry;
			for (var o in setting) {
				if (!Object.prototype[o]) {
					code += enkode(o) + enkode(setting[o]);
				}
			}
			var result = oldRequest.Select({where: 'compare == "' + code + '"'});
			if (cache == true && result[0]) {
				xhr.responseText = result[0].responseText || null;
				xhr.responseXML = result[0].responseXML || null;
				onSuccess(xhr);
			} else {
				xhr = createRequest();
				self.request = true;
				if (isReady(xhr)) {
					if (setting.method.toUpperCase() == "POST") {
						xhr.open(setting.method, setting.address, setting.async);
						xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
						xhr.setRequestHeader("Connection", "close");
						xhr.send(setting.data);
					} else {
						xhr.open(
							setting.method,
							setting.address + "?" + setting.data + "&r=" + new Date().getTime(),
							setting.async
						);
						xhr.send(null);
					}
					onRequest(xhr);
				}
				xhr.onreadystatechange = function() {
					if (isComplete(xhr) && self.request) {
						onStateChange(xhr);
					}
				}
			}
			function createRequest() {
				if (window.ActiveXObject) {
					return new ActiveXObject("Microsoft.XMLHTTP");
				} else {
					return new XMLHttpRequest() || null;
				}
			}
			function onStateChange(XHR) {
				self.request = false;
				if (isSuccess(XHR)) {
					onSuccess(XHR);
					if (cache == true) {
						//cache response data;
						oldRequest.Insert([code, xhr.responseText, xhr.responseXML]);
					} else {
						//update cache data;
						oldRequest.Update({
							responseText: xhr.responseText,
							responseXML: xhr.responseXML,
							where: 'compare == "' + code + '"'
						});
					}
				} else {
					if (!amount) {
						onFailure(XHR);
					} else {
						r.reload = r.reload ? r.reload + 1 : 1;
						self.stopRequest();
						clearTimeout(self.repeat);
						self.repeat = setTimeout(function(){K.request(r)}, setting.delay);
					}
				}
				delete xhr.onreadystatechange;
			}
			function isReady(XHR) {
				return (XHR.readyState == 4 || XHR.readyState == 0);
			}
			function isRequest(XHR) {
				return XHR.readyState < 4;
			}
			function isComplete(XHR) {
				return XHR.readyState == 4;
			}
			function isSuccess(XHR) {
				try {
					return XHR.status == 200;
				} catch(e) {
					return false;
				}
			}
			function onRequest(XHR) {
				if (setting.onRequest instanceof Function) {
					setting.onRequest.call(XHR);
				} else {
					eval(setting.onRequest);
				}
			}
			function onSuccess(XHR) {
				if (setting.onSuccess instanceof Function) {
					setting.onSuccess.call(XHR);
				} else {
					eval(setting.onSuccess);
				}
			}
			function onFailure(XHR) {
				if (setting.onFailure instanceof Function) {
					setting.onFailure.call(XHR);
				} else {
					eval(setting.onFailure);
				}
			}
			function onAbort(XHR) {
				if (setting.onAbort instanceof Function) {
					setting.onAbort.call(XHR);
				} else {
					eval(setting.onAbort);
				}
			}
			this.stopRequest = function() {
				xhr.abort();
				onAbort(xhr);
				this.request = false;
				clearTimeout(this.repeat);
				delete xhr.onreadystatechange;
			};
			this.getHeader = function(name) {
				return xhr.getResponseHeader(name);
			}
		}
	};

	/*
	*	handler general event;
	*/
	Kombai.archive.method = {
		attachEvent: K.create.database({
			fieldName: ["code", "listener"],
			primaryKey: "code",
			ignoreError: true
		}),
		onResize: function(event) {
			var attachEvent = Kombai.archive.method.attachEvent;
			var resize = attachEvent.Select({where: "code like 'onResize%'"});
			var size = resize.length;
			for (var o = 0; o < size; ++ o) {
				resize[o].listener(event);
			}
		},
		onLoad: function(event) {
			var attachEvent = Kombai.archive.method.attachEvent;
			var load = attachEvent.Select({where: "code like 'onLoad%'"});
			var size = load.length;
			for (var o = 0; o < size; ++ o) {
				load[o].listener(event);
			}
		}
	};

	K.addEventOnLoad = function(r) {
		var attachEvent = Kombai.archive.method.attachEvent;
		var source = K(r.toString()).encode().toString();
		attachEvent.Insert(["onLoad:" + source, r]);
	};

	K.addEventOnResize = function(r) {
		var attachEvent = Kombai.archive.method.attachEvent;
		var source = K(r.toString()).encode.toString();
		attachEvent.Insert(["onResize:" + source, r]);
	};

	K.add({element: window, event: {load : Kombai.archive.method.onLoad}});

	K.add({
		element: window,
		event: {
			resize : function() {
				if (Kombai.archive.variable.delay) {
					K.remove.timeout(Kombai.archive.variable.delay);
				}
				Kombai.archive.variable.delay = setTimeout(Kombai.archive.method.onResize, 50);
			}
		}
	});

	/**
	 * Inspects anything object;
	 * @param {anything} object
	 * Example:
	 * 		var num = 2;
	 * 		K.discover(num);
	 *
	 * 		var json = {a: 'b', b: 'c'};
	 * 		K.discover(json);
	 *
	 * 		var str = 'this is the string';
	 * 		K.discover(str);
	 *
	 * 		var ele = K('kombai');
	 * 		K.discover(ele);
	 *
	 * 		//discover console object of firebug :)
	 * 		K.discover(console);
	 */
	K.discover = function(object) {
		if (object === undefined) return;
		removePopup();
		var root = K.create.element({
			id: "k-o-m-b-a-i",
			style: {position:"absolute",top:"0px",left:"0px",width:"0px",height:"0px"}
		});
		K(root).initDragDrop();
		var info = K.create.element({
			style: {position:"relative",top:"0px",borderTop:"1px solid #cccccc",width:"600px",color:"white",padding:"3px",background:"black",zIndex:9999}
		});
		var closeButton = K.create.element({
			innerHTML: "<div style='float:left;'><span style='cursor: pointer;' onclick='K.discover(window);'> {..} window </span>"
						+"<span style='cursor: pointer;' onclick='K.discover(window.document);'> / document </span></div>",
			style: {padding:"3px 0px 0px 0px",height:"20px"}
		});
		var rightButton = K.create.element({
			style:{textAlign:"right",margin:"0px 0px 0px 200px",cursor:"move"}
		});
		var trueClose = K.create.element({
			tagName: "span",
			innerHTML: "<span style='color: red; font-weight: bold; cursor: pointer;'>[ X ]</span>",
            event: {
                click: function(event){
                    var event = event || window.event;
                    event.cancelBubble = true;
                    removePopup();
                }
            }
		});
		var blockContent = K.create.element({
			style: {background:"#848484",border:"1px solid green",height:"300px",overflow:"auto",padding:"10px"},
			event: {
				mousedown: function(event){var event = event || window.event; event.cancelBubble = true;}
			}
		});
		document.body.appendChild(root);
		root.add({
			childNode: K(info).add({
				childNode: K(closeButton).add({
					childNode: K(rightButton).add({
						childNode: trueClose
					})
				})
			}).add({
				childNode: blockContent
			})
		});
        K.discover.childNode = [];
		K.discover.inspect = function (o) {
			var node = document.createElement("div");
			if (/object/.test(typeof o)) {
				var v = {};
				for (var p in o) {
					try {
                        v = o[p];
                    } catch(e) {
                        v = "Can't Access !!!";
                    }
					if (/object/.test(typeof v)) {
                        var id = K.get.generalId();
                        K.discover.childNode[id] = v;
						var div = K.create.element({
							innerHTML: "<span style='margin-right: 2px;'>{..}</span>"
										+ "<span style='color: #9b1a00; cursor: pointer;' onclick='K.discover.inspectChild(this, \"" + id + "\")'>" + p + "</span> : " + v
                                        + "<div style='padding-left: 24px; display: none;'></div>"
						});
						node.appendChild(div);
					} else if (/string/.test(typeof v)) {
						var div = K.create.element({
							innerHTML: "<span style='margin-right: 15px;'>-</span>"
										+ "<span style='color: #9b1a00'>" + p + "</span> : " + v.replace(/</g, "&lt;")
						});
						node.appendChild(div);
					} else {
						var div = K.create.element({
							innerHTML: "<span style='margin-right: 15px;'>-</span>"
										+ "<span style='color: #9b1a00'>" + p + "</span> : " + v
						});
						node.appendChild(div);
					}
				}
			} else if (/string/.test(typeof v)) {
				node.innerHTML = o.replace(/</g, "&lt;");
			} else {
				node.innerHTML = o;
			}
			return node;
		}
        K.discover.inspectChild = function(element, id) {
            var parent = element.parentNode;
            var target = K(parent).last();
            if (K(target).first()) {
                if (target.style.display != 'block') {
                    target.style.display = 'block';
                } else {
                    target.style.display = 'none';
                }
            } else {
                target.style.display = 'block';
                target.appendChild(K.discover.inspect(K.discover.childNode[id]));
            }
        }
        function removePopup() {
			if (document.getElementById("k-o-m-b-a-i")) {
				K.remove.element(K("k-o-m-b-a-i"));
                K.discover.childNode = null;
                K.discover.childNode = [];
			}
		}

		blockContent.appendChild(K.discover.inspect(object));
	};
